package util;

import exceptions.InvalidParameterException;
import exceptions.NullParameterException;

public class CheckParameters {
	public static void checkStringEmpty(String s, String label) throws NullParameterException, InvalidParameterException{
		checkNull(s, label);
		if (s.trim().equals("")) throw new InvalidParameterException(label+" cannot be empty");
	}
	
	public static void checkNull(Object o, String label) throws NullParameterException {
		if (o == null) throw new NullParameterException("Object "+label+" cannot be null");
	}
	
	public static void checkPositiveOrZero(double i, String label) throws InvalidParameterException {
		if (i < 0) throw new InvalidParameterException("Number "+label+" cannot be negative ("+i+")");
	}
	
	public static void checkNotZero(double i, String label) throws InvalidParameterException {
		if (i == 0) throw new InvalidParameterException("Number "+label+" cannot be 0");
	}
}
